home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / cvs / sprite / checkin.csh < prev    next >
Linux/UNIX/POSIX Shell Script  |  1991-07-29  |  8KB  |  260 lines

  1. #!/bin/csh
  2. #
  3. # $Id: checkin.csh,v 1.2 91/07/29 11:52:39 jhh Exp $
  4. #
  5. #   Copyright (c) 1989, Brian Berliner
  6. #
  7. #   You may distribute under the terms of the GNU General Public License
  8. #   as specified in the README file that comes with the CVS 1.0 kit.
  9. #
  10. #############################################################################
  11. #                                        #
  12. # This script is used to check in sources from vendors.              #
  13. #                                        #
  14. #    Usage: checkin repository Vendor_Tag Vendor_Release_Tag            #
  15. #                                        #
  16. # The repository is the directory where the sources should            #
  17. # be deposited, the Vendor_Tag is the symbolic tag for the             #
  18. # vendor branch of the RCS release tree, and the Vendor_Release_Tag        #
  19. # is the symbolic tag for this release.                      #
  20. #                                        #
  21. # checkin traverses the current directory, ensuring that an             #
  22. # identical directory structure exists in the repository directory.  It        #
  23. # then checks the files in in the following manner:                #
  24. #                                        #
  25. #        1) If the file doesn't yet exist, check it in             #
  26. #            as revision 1.1                        #
  27. #        2) Tag branch 1.1.1 with the vendor tag                #
  28. #        3) Check the file into the vendor branch,             #
  29. #            labeling it with the Vendor_Release_Tag            #
  30. #        4) If the file didn't previously exist,             #
  31. #            make the vendor branch the default branch        #
  32. #                                        #
  33. # The script also is somewhat verbose in letting the user know what is        #
  34. # going on.  It prints a diagnostic when it creates a new file, or updates  #
  35. # a file that has been modified on the trunk.                       #
  36. #                                        #
  37. #############################################################################
  38.  
  39. set vbose = 0
  40. set message = ""
  41. set cvsbin = /sprite/cmds
  42. set rcsbin = /sprite/cmds
  43. set grep = /sprite/cmds/grep
  44. set message_file = /tmp/checkin.$$
  45. set got_one = 0
  46.  
  47. if ( $#argv < 3 ) then
  48.     echo "Usage: checkin [-v] [-m message] [-f message_file] repository"
  49.     echo "    Vendor_Tag Vendor_Release_Tag [Vendor_Release_tag...]"
  50.     exit 1
  51. endif
  52. while ( $#argv )
  53.     switch ( $argv[1] )
  54.         case -v:
  55.             set vbose = 1
  56.         breaksw
  57.     case -m:
  58.         shift
  59.         echo $argv[1] > $message_file
  60.         set got_one = 1
  61.         breaksw
  62.     case -f:
  63.         shift
  64.         set message_file = $argv[1]
  65.         set got_one = 2
  66.         breaksw
  67.     default:
  68.         break
  69.     endsw
  70.     shift
  71. end
  72. if ( $#argv < 3 ) then
  73.     echo "Usage: checkin [-v] [-m message] [-f message_file] repository"
  74.     echo "    Vendor_Tag Vendor_Release_Tag [Vendor_Release_tag...]"
  75.     exit 1
  76. endif
  77. set repository = $argv[1]
  78. shift
  79. set vendor = $argv[1]
  80. shift
  81. set release = $argv[1]
  82. shift
  83. set extra_release = ( $argv )
  84.  
  85. if ( ! $?CVSROOT ) then
  86.     echo "Please set the environmental variable CVSROOT to the root"
  87.     echo "    of the tree you wish to update"
  88.     exit 1
  89. endif
  90.  
  91. if ( $got_one == 0 ) then
  92.     echo "You must use either the -m or -f option"
  93.     exit 1
  94. endif
  95.  
  96. umask 2
  97.  
  98. set update_dir = ${CVSROOT}/${repository}
  99. if ( -d SCCS ) then
  100.     sccs get SCCS/* >& /dev/null
  101. endif
  102. if ( -d RCS ) then
  103.     $rcsbin/co RCS/* >& /dev/null
  104. endif
  105. foreach name ( * .[a-zA-Z0-9]* )
  106.     if ( $name == SCCS ) then 
  107.     continue
  108.     endif
  109.     if ( $name == RCS ) then 
  110.     continue
  111.     endif
  112.     if ( $vbose ) then 
  113.     echo "Updating ${repository}/${name}"
  114.     endif
  115.     if ( -d $name ) then
  116.     if ( ! -d ${update_dir}/${name} ) then
  117.         echo "WARNING: Creating new directory ${repository}/${name}"
  118.         mkdir ${update_dir}/${name}
  119.         if ( $status ) then
  120.         echo "ERROR: mkdir failed - aborting"
  121.         exit 1
  122.         endif
  123.     endif
  124.     chdir $name
  125.     if ( $status ) then
  126.         echo "ERROR: Couldn\'t chdir to $name - aborting" 
  127.         exit 1
  128.     endif
  129.     if ( $vbose ) then
  130.         $cvsbin/checkin -v -f $message_file ${repository}/${name} $vendor $release $extra_release
  131.     else
  132.         $cvsbin/checkin -f $message_file ${repository}/${name} $vendor $release $extra_release
  133.     endif
  134.     if ( $status ) then 
  135.         exit 1
  136.     endif
  137.     chdir ..
  138.     else
  139.     if ( ! -f $name ) then
  140.         echo "WARNING: $name is neither a regular file" 
  141.         echo "       nor a directory - ignored"
  142.         continue
  143.     endif
  144.     set file = ${update_dir}/${name},v
  145.     set new = 0
  146.     set comment = ""
  147.     grep -s '\$Log.*\$' ${name}
  148.     if ( $status == 0 ) then
  149.         set myext = ${name:e}
  150.         set knownext = 0
  151.         foreach xx ( "c" "csh" "e" "f" "h" "l" "mac" "me" "mm" "ms" "p" "r" "red" "s" "sh" "sl" "cl" "ml" "el" "tex" "y" "ye" "yr" "" "SH")
  152.         if ( "${myext}" == "${xx}" ) then
  153.             set knownext = 1
  154.             break
  155.         endif
  156.         end
  157.         if ( $knownext == 0 ) then
  158.         echo For file ${file}:
  159.         grep '\$Log.*\$' ${name}
  160.         echo -n "Please insert a comment leader for file ${name} > "
  161.         set comment = $<
  162.         endif
  163.     endif
  164.     if ( ! -f $file ) then
  165.         if ( ! -f ${update_dir}/Attic/${name},v ) then
  166.             echo "WARNING: Creating new file ${repository}/${name}"
  167.         if ( "${comment}" != "" ) then
  168.             $rcsbin/rcs -q -i -c"${comment}" -t/dev/null $file
  169.         endif
  170.             $rcsbin/ci -q -u1.1 -t/dev/null $file 
  171.             if ( $status ) then
  172.             echo "ERROR: Initial check-in of $file failed - aborting"
  173.             exit 1
  174.             endif
  175.             set new = 1
  176.         else 
  177.         set file = ${update_dir}/Attic/${name},v
  178.         echo "WARNING: Updating ${repository}/Attic/${name}"
  179.             set headbranch = `sed -n '/^head/p; /^branch/p; 2q' $file`
  180.             if ( $#headbranch != 2 && $#headbranch != 4 ) then
  181.             echo "ERROR: corrupted RCS file $file - aborting"
  182.             endif
  183.         set head = "$headbranch[2]"
  184.         set branch = ""
  185.         if ( $#headbranch == 4 ) then
  186.             set branch = "$headbranch[4]"
  187.         endif
  188.             if ( "$head" == "1.1;" && "$branch" != "1.1.1;" ) then
  189.             ${rcsbin}/rcsdiff -q -r1.1 $file > /dev/null
  190.             if ( ! $status ) then
  191.                 set new = 1
  192.             endif
  193.             else
  194.                 if ( "$branch" != "1.1.1;" ) then
  195.                 echo -n "WARNING: Updating locally modified file "
  196.             echo    "${repository}/Attic/${name}"
  197.                 endif
  198.             endif
  199.         endif
  200.     else
  201.         set headbranch = `sed -n '/^head/p; /^branch/p; 2q' $file`
  202.         if ( $#headbranch != 2 && $#headbranch != 4 ) then
  203.         echo "ERROR: corrupted RCS file $file - aborting"
  204.         endif
  205.         set head = "$headbranch[2]"
  206.         set branch = ""
  207.         if ( $#headbranch == 4 ) then
  208.         set branch = "$headbranch[4]"
  209.         endif
  210.         if ( "$head" == "1.1;" && "$branch" != "1.1.1;" ) then
  211.         ${rcsbin}/rcsdiff -q -r1.1 $file > /dev/null
  212.         if ( ! $status ) then
  213.             set new = 1
  214.         endif
  215.         else
  216.             if ( "$branch" != "1.1.1;" ) then
  217.             echo -n "WARNING: Updating locally modified file "
  218.             echo    "${repository}/${name}"
  219.             endif
  220.         endif
  221.     endif
  222.     $rcsbin/rcs -q -N${vendor}:1.1.1 $file
  223.     if ( $status ) then
  224.         echo "ERROR: Attempt to set Vendor_Tag in $file failed - aborting"
  225.         exit 1
  226.     endif
  227.     set lock_failed = 0
  228.     $rcsbin/rcs -q -l${vendor} $file >& /dev/null
  229.     if ( $status ) then
  230.         set lock_failed = 1
  231.     endif
  232.     if ( "${comment}" != "" ) then
  233.         $rcsbin/rcs -q -c"${comment}" $file
  234.     endif
  235.     $rcsbin/ci -q -f -u${vendor} -N${release} $file < $message_file 
  236.     if ( $status ) then
  237.         echo "ERROR: Check-in of $file failed - aborting"
  238.         if ( ! $lock_failed ) then
  239.             $rcsbin/rcs -q -u${vendor} $file
  240.         endif
  241.         exit 1
  242.     endif
  243.     foreach tag ( $extra_release )
  244.         $rcsbin/rcs -q -N${tag}:${release} $file
  245.         if ( $status ) then
  246.         echo "ERROR: Couldn't add tag $tag to file $file"
  247.         continue
  248.         endif
  249.     end
  250.     if ( $new ) then
  251.         $rcsbin/rcs -q -b${vendor} $file
  252.         if ( $status ) then
  253.         echo "ERROR: Attempt to change default branch failed - aborting"
  254.         exit 1
  255.         endif
  256.     endif
  257.     endif
  258. end
  259. if ( $got_one == 1 ) rm $message_file
  260.